#include <stdio.h>
#include <string.h>

void getNext(char* pattern, int next[]) {
    int len = strlen(pattern);
    next[0] = -1;
    int i = 0, j = -1;

    while (i < len - 1) {
        if (j == -1 || pattern[i] == pattern[j]) {
            i++;
            j++;
            next[i] = j;
        }
        else {
            j = next[j];
        }
    }
}

int main() {
    char pattern[100];
    int next[100];

    scanf("%s", pattern);

    getNext(pattern, next);
    for (int i = 0; i < strlen(pattern)-1; i++) {
        printf("%d ", next[i]+1);
    }
    printf("%d",next[strlen(pattern) - 1]+1);
    return 0;
}